package com.mygdx.game.Stage.Fight;


import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Disposable;


public class BloodBar extends Actor implements Disposable {

    private Texture platform;//进度条底座的图片
    private Texture bar;//进度条图片
    private float height = 25;
    private float maxWidth = 200;
    private float maxHp;
    private float currentHp;

    private int x;
    private int y;

    @Override
    public void draw(Batch batch, float parentAlpha) {
        batch.draw(platform, x+100, y+300,maxWidth, height);
        batch.draw(bar, x+100, y+300,(currentHp/maxHp)*maxWidth, height);
    }

    public BloodBar() {
        super();
        platform = new Texture(Gdx.files.internal("com/mygdx/game/Stage/Fight/血条框.png"));
        bar = new Texture(Gdx.files.internal("com/mygdx/game/Stage/Fight/血条.png"));
    }
    public void set(int x, int y,float maxHp, float currentHp){
        this.x=x;
        this.y=y;
        this.maxHp=maxHp;
        this.currentHp=currentHp;
    }

    @Override
    public void dispose() {
        platform.dispose();
        bar.dispose();
    }

}
